package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.HashMap;


@Getter
@Setter
@ToString
@JsonIgnoreProperties("handler")
public class User extends BaseDomain {

    private static final int GENDER_SECRET = -1;    // 保密
    private static final int GENDER_MAN = 0;        // 男
    private static final int GENDER_WOMAN = 1;      // 女

    private static final int ISVIP_TRUE = 1;        // 是会员
    private static final int ISVIP_FALSE = 0;      // 不是会员
    // 邮箱
    private String email;
    // 昵称
    private String nickName;
    // 密码
    private String password;
    // 常住地
    private String place;
    // 头像
    private String headImgUrl;
    // 性别
    private Integer gender = GENDER_SECRET;
    // 封面
    private String coverImgUrl;
    // 签名
    private String sign;
    //关注人数
    private Integer followCount;
    //粉丝人数
    private Integer fansCount;

    //用户点赞过的点评文章
    private News news;

    //是否VIP
    private Integer isVIP = ISVIP_FALSE;

    //用户余额
    private Integer balance;

    public Integer getIsVIP() {
        Integer VIP = null;
        if (isVIP == ISVIP_TRUE) {
            VIP = 1;
        } else if (isVIP == ISVIP_FALSE) {
            VIP = 0;
        } else {
            VIP = 0;
        }
        return VIP;
    }


    // 性别对应的名称
    public String getGenderName() {
        String genderName;
        if (gender == GENDER_WOMAN) {
            genderName = "女";
        } else if (gender == GENDER_MAN) {
            genderName = "男";
        } else {
            genderName = "保密";
        }
        return genderName;
    }

    public String getJson() {
        HashMap<String, Object> map = new HashMap();
        map.put("id", this.id);
        map.put("isVIP", this.isVIP);
        return JSONUtils.toJSONString(map);
    }
}